<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="<%=basePath%>resources/lib/html5.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/respond.min.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="<%=basePath%>resources/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>resources/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>resources/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>resources/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>resources/static/h-ui.admin/skin/default/skin.css" id="skin" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>游戏列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 游戏管理 <span class="c-gray en">&gt;</span> 游戏列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form action="<%=basePath%>game/addGame" method="post" class="form form-horizontal" id="form-game-add">
		<div class="text-c"> 游戏名：
			<input type="text" class="input-text" style="width:250px" placeholder="输入游戏名" id="" name="name">
			<button type="submit" class="btn btn-success radius" id="" name="">增加游戏</button>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red"></span></label>
				<div class="formControls col-xs-8 col-sm-9">
					<c:if test="${not empty msg}"><img src="<%=basePath%>resources/rrr2.png" width="30" height="30">
					</c:if><font color="red" size="4">${msg}</font>
				</div>
			</div>
		</div>
	</form>
	<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="100">游戏ID</th>
				<th width="100">游戏名称</th>
				<th width="100">创建人</th>
				<th width="50">操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${games}" var="game">
			<tr class="text-c">
				<td>${game.id}</td>
				<td>${game.name}</td>
				<td>${game.operate}</td>
				<td>
					<a title="删除" href="javascript:;" onclick="order_del(this,${game.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<script type="text/javascript" src="<%=basePath%>resources/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/static/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});

	$("#form-game-add").validate({
		rules:{
			name:{
				required:true,
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			//$(form).ajaxSubmit();
			var index = parent.layer.getFrameIndex(window.name);
			//parent.$('.btn-refresh').click();
			parent.layer.close(index);
		}
	});
});
function order_del(obj,id){
	layer.confirm('确认要删除吗？可能会影响有关订单的展示！！！',function(index){
		$.ajax({
			url:"<%=basePath%>game/deleteGame",
			data:{"id":id},
			type:"post",
			cache: false,
			success:function (data) {
				if(data.code==0){
					$(obj).parents("tr").remove();
					layer.msg('已删除!',{icon:1,time:2000});
				}else {
					layer.msg(data.message,{icon:5,time:2000});
				}
			}
		});

	});
}
</script> 
</body>
</html>